package com.example.dormlist.controller;

import com.example.dormlist.entity.DormitoryBuilding;
import com.example.dormlist.service.DormitoryBuildingService;
import lombok.AllArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@AllArgsConstructor
@RequestMapping("/dorm")
public class DormitoryController {
    private final DormitoryBuildingService dormitoryBuildingService;

    @GetMapping("/findall")
    public ResponseEntity getAllDorms(HttpServletRequest request) {
        List<DormitoryBuilding> buildingList = dormitoryBuildingService.findAll();
        return new ResponseEntity(buildingList, HttpStatus.OK);
    }
}
